package com.baturu.vin.benz.dal.dao;

import com.baturu.vin.benz.dto.BenzFootNoteInfoDTO;
import com.baturu.vin.benz.dto.BenzFootnoteDetailDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author liangguanglong
 * @Date 16/7/14
 * @Time 下午5:42
 */
public interface BenzFootNoteInfoDAO {

    @Results(value = {
            @Result(column = "ftntnum", property = "footnote"),
    })
    @Select({"<script>select id,catnum,groupNum,ftntnum,descidx from bm_footnotes_v2 where catnum in " ,
            "<foreach item='item' index='index' collection='catNums' open='(' separator=',' close=') '>",
            "#{item}",
            "</foreach>",
            " and groupNum in",
            "<foreach item='item1' index='index' collection='groupNums' open='(' separator=',' close=') '>",
            "#{item1}",
            "</foreach>",
            " and ftntnum in",
            "<foreach item='item2' index='index' collection='footNotes' open='(' separator=',' close=') '>",
            "#{item2}",
            "</foreach>",
            "</script>"})
    List<BenzFootNoteInfoDTO> findFootNote(@Param("catNums") List<String> catNums, @Param("groupNums") List<String> groupNums, @Param("footNotes") List<String> footNotes);
    @Results(value = {
            @Result(column = "text", property = "content")
    })
     @Select({"<script>select id,descidx,lang,text from bm_footnotes_dictionary_v where lang in ('N','Z') and descidx in " ,
            "<foreach item='item' index='index' collection='descIdxes' open='(' separator=',' close=') '>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<BenzFootnoteDetailDTO> findFootNoteDetail(@Param("descIdxes") List<String> descIdxes);


    @Results(value = {
            @Result(column = "ftntnum", property = "footnote"),
            @Result(column = "text", property = "content"),
            @Result(column = "abbr", property = "contentType")
    })
    @Select({"<script>select f.id,f.descidx,f.catNum,f.groupNum,f.ftntnum,d.abbr,d.text from bm_footnotes_dictionary_v d JOIN bm_footnotes_v2 f on  d.descidx=f.descidx  where d.lang='N' and  catnum in " ,
            "<foreach item='item' index='index' collection='catNums' open='(' separator=',' close=') '>",
            "#{item}",
            "</foreach>",
            " and groupNum in",
            "<foreach item='item1' index='index' collection='groupNums' open='(' separator=',' close=') '>",
            "#{item1}",
            "</foreach>",
            " and ftntnum in",
            "<foreach item='item2' index='index' collection='footNotes' open='(' separator=',' close=') '>",
            "#{item2}",
            "</foreach>",
            "</script>"})
    List<BenzFootNoteInfoDTO> findFootNoteText(@Param("catNums") List<String> catNums, @Param("groupNums") List<String> groupNums, @Param("footNotes") List<String> footNotes);


}
